#ifndef __VISUALWIDGET_H__
#define __VISUALWIDGET_H__

#include <QtGui/QVBoxLayout>
#include <QtGui/QHBoxLayout>
#include <QtGui/QGridLayout>
#include <QtCore/QObject>
#include <QtGui/QWidget>
#include <QtGui/QGroupBox>
#include <QtGui/QListWidget>
#include <QtGui/QPushButton>
#include <QtGui/QComboBox>
#include <QtGui/QLabel>
#include <QtGui/QLineEdit>
#include <QtGui/QFileDialog>
#include <QtGui/QCheckBox>
#include <QtCore/QRectF>
#include <QtGui/QSpacerItem>
#include <QtGui/QStatusBar>

#include "verema_graphicsview.h"
#include "verema_graphicsscene.h"
#include "database_sqlite.h"
#include "config.h"
#include "unit.h"
#include "subunit.h"
#include "item.h"
#include "image.h"


namespace verema {

/**
 * \brief class containing the widget for the visualized view mode
 */
class VisualWidget : public QWidget
{
	Q_OBJECT

public:
	/**
	  * \brief constructor
	  */
	VisualWidget();

	/**
	  * \brief destructor
	  */
	~VisualWidget();

	/**
	 * \brief reimplementated function to refresh data in the widget on show
	 */
    void show();

    /**
     * \brief function for setting the main window
     */
    void setStatusBar(QStatusBar *statusbar);

private:

    QHBoxLayout hbl_mainlayout;
    QVBoxLayout vbl_left, vbl_right;

    QGroupBox grb_select, grb_item, grb_coords, grb_size, grb_properties;
    QVBoxLayout vbl_selectbox, vbl_item;

    QGridLayout grl_item, grl_coords, grl_size, grl_properties;

    QHBoxLayout hbl_coords_size, hbl_image;

    QComboBox cmb_unit, cmb_subunit;
    QLabel lbl_unit, lbl_subunit, lbl_item_desc, lbl_x, lbl_y, lbl_w, lbl_h, lbl_item_name, lbl_image_path;
    QLineEdit led_item_desc, led_x, led_y, led_w, led_h, led_item_name, led_image_path;

    QListWidget lst_items;

    // btn_frame_draw_free is for future feature
    QPushButton btn_del, btn_rename_item, btn_frame_rect_add, /*btn_frame_draw_free,*/ btn_frame_remove, btn_select_image;

    QFileDialog fld_select_image;
    QCheckBox chk_show_image;
    GraphicsView gpv_image_view;
    GraphicsScene gps_scene;

	Database_Sqlite database;

	std::vector<verema::Unit> unit_vector;
	std::vector<verema::Subunit> subunit_vector;
	std::vector<verema::Item> item_vector;

	QString str_available_image_formats;

	QStatusBar *status_bar;

private slots:

	/**
	 * \brief slot for the unit combobox
	 */
	void unitActivated();

	/**
	 * \brief slot for the subunit combobox
	 */
	void subunitActivated();

	/**
	 * \brief slot for the item combobox
	 */
	void itemActivated();

    /**
     * \brief slot for the item description box
	 */
    void itemDescrEdited();

    /**
     * \brief slot for changing ItemBox Data
     */
    void itemBoxEdited();

    /**
     * \brief slot for changing the image path
     */
    void imagePathEdited();

    /**
	 * \brief slot for the changeItemName button
	 */
    void changeItemName();

    /**
	 * \brief slot for the remove button
	 */
    void removeItem();

	/**
	 * \brief slot for the image select button
	 */
    void selectImage();

    /**
	 * \brief slot for refreshing the image path
	 */
    void refreshImage();

    /**
     * \brief slot for refreshing the graphicscene
     */
    void refreshScene();

    /**
     * \brief slot for saving changes made for the image path
     */
    void savePathToDatabase();

    /**
     * \brief slot for button add rect frame activation
     */
    void addRectActivated();

    /**
     * \brief slot for resetting the editing mode
     */
    void resetEditMode();

    /**
     * \brief slot for delete frame button clicked
     */
    void delButtonActivated();

    /**
     * \brief slot for removing rects from graphicsscene
     */
    void rectRemoved(int id);

    /**
     * \brief slot for adding a rect
     */
    void rectAdded(QRectF rect_added);

    /**
     * \brief slot for moving in the graphicsview
     */
     void moveinView(int, int);

    /**
     * \brief slot for leaving the graphicsview
     */
    void leftView();

    /**
     * \brief slot for changing a rect in the scene
     */
    void rectChanged(QRectF new_rect/*, int ID*/);

    /**
     * \brief slot for changing a rect state in the scene
     */
    void rectStateChanged(int id, bool state);
};

} // namespace verema

#endif // __VISUALWIDGET_H__
